{include file="common/header" title="系统管理"}
{include file="common/crumb" subName="系统管理" tabName="配置管理"}

<div class="x-body">
    <div class="layui-tab layui-tab-brief" lay-filter="tabFilter">
        <ul class="layui-tab-title">
            <li class="layui-this">站点设置</li>
            <li>SEO设置</li>
            <li>博主信息</li>
            <li>其它设置</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item  layui-show">
                <form class="layui-form layui-form-pane" action="" enctype="multipart/form-data" >
                    <!--隐藏域-->
                    <input type="hidden" name="zh_name" value="站点设置" >
                    <input type="hidden" name="en_name" value="web_setting" >
                    <!--隐藏域-->

                    <div class="layui-form-item">
                        <label class="layui-form-label">站点名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="web_name" autocomplete="off" placeholder="请输入标题" class="layui-input" value="{$web_setting['web_name'] ?? ''}" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">站点LOGO</label>
                        <div class="layui-input-inline">
                            <button type="button" class="web_logo layui-btn uploadBtn layui-btn-danger"><i class="layui-icon"></i>上传图片</button>
                            <input type="hidden" name="web_logo" value="{$web_setting['web_logo']??''}" >
                        </div>
                    </div>
                    <div class="layui-upload">
                        <div class="layui-upload-list">
                            <img data-old="{$web_setting['web_logo']??''}" src="{$web_setting['web_logo']??''}" class="web_logo layui-upload-img" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备案号</label>
                        <div class="layui-input-block">
                            <input type="text" name="copy" value="{$web_setting['copy']??''}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">统计</label>
                        <div class="layui-input-block">
                            <textarea name="statistics" placeholder="请输入统计代码" class="layui-textarea">{$web_setting['statistics']??''}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="filter">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form layui-form-pane" action="">
                    <!--隐藏域-->
                    <input type="hidden" name="zh_name" value="SEO设置" >
                    <input type="hidden" name="en_name" value="seo_setting" >
                    <!--隐藏域-->

                    <div class="layui-form-item">
                        <label class="layui-form-label">关键词</label>
                        <div class="layui-input-block">
                            <input type="text" name="keywords" value="{$seo_setting['keywords']??''}" autocomplete="off" placeholder="请输入关键词" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">描述</label>
                        <div class="layui-input-block">
                            <textarea name="description" placeholder="请输入描述" class="layui-textarea">{$seo_setting['description']??''}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="filter">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form layui-form-pane" action="">
                    <!--隐藏域-->
                    <input type="hidden" name="zh_name" value="博主信息" >
                    <input type="hidden" name="en_name" value="owner_setting" >
                    <!--隐藏域-->

                    <div class="layui-form-item">
                        <label class="layui-form-label">QQ号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="qq" value="{$owner_setting['qq']??''}" autocomplete="off" placeholder="请输入QQ号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">微信号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="weixi" value="{$owner_setting['weixi']??''}" autocomplete="off" placeholder="请输入微信号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">微信二维码</label>
                        <div class="layui-input-inline">
                            <button type="button" class="weixin_ma uploadBtn layui-btn layui-btn-danger"><i class="layui-icon"></i>上传图片</button>
                            <input type="hidden" name="weixin_ma" value="{$owner_setting['weixin_ma']??''}" >
                        </div>
                    </div>
                    <div class="layui-upload">
                        <div class="layui-upload-list">
                            <img data-old="{$owner_setting['weixin_ma']??''}" src="{$owner_setting['weixin_ma']??''}" class="weixin_ma layui-upload-img" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="filter">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form layui-form-pane" action="">
                    <!--隐藏域-->
                    <input type="hidden" name="zh_name" value="其它设置" >
                    <input type="hidden" name="en_name" value="other_setting" >
                    <!--隐藏域-->

                    <div class="layui-form-item">
                        <label class="layui-form-label">超级管理员ID</label>
                        <div class="layui-input-inline">
                            <input type="number" name="admin_id" value="{$other_setting['admin_id']??''}" autocomplete="off" placeholder="请输入超级管理员ID" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章每页条数</label>
                        <div class="layui-input-inline">
                            <input type="number" name="article_page" value="{$other_setting['article_page']??''}" autocomplete="off" placeholder="请输入文章每页条数" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">作品每页条数</label>
                        <div class="layui-input-inline">
                            <input type="number" name="works_page" value="{$other_setting['works_page']??''}" autocomplete="off" placeholder="请输入作品每页条数" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">微语每页条数</label>
                        <div class="layui-input-inline">
                            <input type="number" name="mood_page" value="{$other_setting['mood_page']??''}" autocomplete="off" placeholder="请输入微语每页条数" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">评论每页条数</label>
                        <div class="layui-input-inline">
                            <input type="number" name="message_page" value="{$other_setting['message_page']??''}" autocomplete="off" placeholder="请输入评论每页条数" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="filter">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['upload','element','form'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form
            , element = layui.element;

        //普通图片上传
        //设定文件大小限制
        var uploadObj = upload.render({
            elem: '.uploadBtn'
            ,url: '/admin/Article/upload'
            ,size: 120 //限制文件大小，单位 KB
            ,done: function(res, index, upload){
                var item = this.item;
                var uploadClassName = item[0]['classList'][0];

                if (res.code === 200){
                    $("img."+uploadClassName).attr('src',res.url);
                    $("input[name='"+uploadClassName+"']").val(res.url);
                }
            }
        });

        form.on('submit',function (data) {
            
            if (data.field.en_name == 'web_setting') {
                if ($("#pic").attr('data-old') != data.field.web_logo){
                    $.get('{:url("base/delAccessory")}',{accessory_path:$("#pic").attr('data-old')});
                }
            }

            $.post('{:url("store")}',data.field,function(res){

                layer.msg(res.msg,{time:1000},function(){
                    if (res.code === 0) {
                        location.reload();
                    }
                });
            });
            return false;
        })

    });
</script>
</body>

</html>